<?php
/**
 * LazyFast Index contraller 
 * ============================================================================
 * ©2008 Jeemon software
 * http://www.jeemon.com
 * ----------------------------------------------------------------------------
 * This is an open source project. You can modify and republish this project.
 * But don't be used for bussiness.
 * ============================================================================
 * $Author: Jeemon Wong <shadow.iqka@gmail.com>
 * $Date$
 * $Id$
 */

class CIndex {
	
	//主程序入口
	function main() {
		$sapi = m("sapi");
		$xn = $sapi->factory("xiaonei");
		// $xn->debug();
		$uid = $xn->get_uid();
		$info = $xn->get_user_info( $uid );
		// echo "<pre>";
		// print_r($info);
		// echo "</pre>";
		
		//DEBUG LOCAL ONLY
		$info[0] = array();
		
		$info[0] = array_merge(
			array(
				"id"=>0
			), 
			$info[0]);
			
			
	
		$dbutil = m("dbutil");
		$dbutil->array2table("member", $info[0]);
		$dbutil->array2sql("member", "UserInfo", $info[0]);
	
		$info[1] = array(  //每天一条Feed
			"id"=>0,
			"uid"=>0,
			"resource_id"=>0,
			"title"=>'{"actor":"王伟平","title":"启动了魔力8号球..."}',
			"data"=>'{"data":"今天上午九点28分,做了一次预测,结果是YES"}',
			"format"=> 'JSON'
		);
		
		$dbutil->array2table("feed", $info[1]);
		$dbutil->array2sql("feed", "FeedInfo", $info[1]);
		$member = m("member");
		v('index', $member);
		
	}
	
	//获取玩家信息
	function get_user_info() {
		echo json_encode(array("name"=>"王卫平"));
		
		return;
		$sapi = m("sapi");
		$xn = $sapi->factory("xiaonei");
		$xn->debug();
		$uid = $xn->get_uid();
		$info = $xn->get_user_info( $uid );
		echo json_encode($info[0]);
	}
	
	//测试iAPI
	function iapi() {
		$sapi = m("sapi");
		$xn = $sapi->factory("xiaonei");
		$xn->debug();
		$id =  $xn->get_uid();
		$ids = $xn->get_user_friends_id( $id );
		$interface = array();
		$interface["hello"] = $xn->hello();
		$interface["get_uid"] = $xn->get_uid();
		$interface["get_user_friends_id"] = $xn->get_user_friends_id( $id );
		$interface["get_user_friends"] = $xn->get_user_friends( $id );
		$interface["get_user_info"] = $xn->get_user_info($id);
		$interface["send_notice"] = $xn->send_notice(array($id), "test");
		
		echo "<pre>";
		print_r($interface);
		echo "</pre>";
		
	}

}